package com.mybank.fundtrans.controller;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mybank.fundtrans.entity.Fund;
import com.mybank.fundtrans.service.impl.FundServiceImpl;
import com.mybank.fundtrans.utils.CastRequestToMap;

public class UpdateFundController extends HttpServlet {
	
	private Fund fund;
	private FundServiceImpl fundService;
	private static final long serialVersionUID = 1L;

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) {


		Map map = CastRequestToMap.castRequestToMap(request);
 
        fund =new Fund();
        fund.setName(map.get("fundname").toString());
        fund.setPrice(Double.parseDouble(map.get("fundprice").toString()));
        fund.setDescription(map.get("funddesri").toString());
        fund.setStatus(map.get("fundtype").toString());
        fund.setCreateTime(new Date());
        fundService=new FundServiceImpl();
        fundService.updateFund(fund);
	}
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doGet(req, resp);
	}
}
